package com.character.controller;


import com.character.entity.MyReturn;

/**
 * @author:高杰领
 * @date:2021/11/24 16:44
 * @description:
 * @version:
 **/

public class BaseController {
    /**
     *
     * @param object
     * @param count
     * @return com.cloudwise.entity.MyReturn
     * @author 高冷
     * @description:操作数据库成功需要执行此方法,
     * @date 2021/11/25 15:14
     */
    public MyReturn success(Object object, Long ...count){
        MyReturn myReturn=new MyReturn();
        //操作成功消息放入对象
        myReturn.setMsg("操作成功");
        //成功标志0放入myReturn对象
        myReturn.setCode(0);
        //放入需要向前台传输的数据
        myReturn.setData(object);
        //count指数据的长度,如果没有默认为空,如果有则放入myReturn
        if(count!=null&&count.length>0){
            myReturn.setCount(count[0]);
        }
        return myReturn;
    }
    /**
     *
     * @param object
     * @param count
     * @return com.cloudwise.entity.MyReturn
     * @author 高冷
     * @description:操作数据库失败需要执行此方法
     * @date 2021/11/25 15:14
     */
    public MyReturn failed(Object object, Long ...count){
        MyReturn myReturn=new MyReturn();
        //操作失败消息放入myReturn对象
        myReturn.setMsg("操作失败");
        myReturn.setCode(1);
        myReturn.setData(object);
        if(count!=null && count.length>0){
            myReturn.setCount(count[0]);
        }
        return myReturn;
    }
    public MyReturn failed(String msg){
        MyReturn myReturn = new MyReturn();
        myReturn.setMsg(msg);
        myReturn.setCode(1);
        return myReturn;
    }
}
